from mydb.odbc import atable as atable1
from mydb.mysql import atable as atable2

zakazi=atable1()
zakazi.table.base.dsn='payroll'
zakazi.table.base.netdrive='E:\\Py\\MyPy\\progs\\payroll\\files'
zakazi.name='zakazi'
zakazi.fields=[
['gr_num_','c (10)','', ''],
['dir_','c (250)','', ''],
['name_','c (250)','', ''],
['prim_','c (10)','', ''],
['sec_','c (10)','', ''],
['adv_','c (10)','', ''],
['gri_','c (10)','', ''],
['gri1_','c (10)','', '']
]

directions=atable2()
directions.name='directions'
rows=directions.generate()

zakazi.drop()
zakazi.create()
zakazi.table.base.connect()


for row in rows:
	temp=[]
	for item in row:
		if item:
			temp+=[item]
		else:
			temp+=['']
	zakazi.table.base.cursor.execute("insert into zakazi(gr_num_, dir_, name_, prim_, sec_, adv_, gri_, gri1_) values ('"+ "', '".join(temp)+"')")
	zakazi.table.base.conn.commit()

zakazi.table.base.disconnect()